+2005-12-05 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkwidget.c:
+ * gtk/gtkuimanager.c:
+ * gtk/gtktreedatalist.c:
+ * gtk/gtktext.c:
+ * gtk/gtkmain.c:
+ * gtk/gtkitemfactory.c:
+ * gtk/gtkseparator.[hc]:
+ * gtk/gtkclist.[hc]:
+ * gtk/gtkctree.c:
+ * gtk/gtkgc.c: Use g_slice instead of mem chunks.
+
2005-12-05 Michael Natterer <mitch@imendio.com>
* gdk/x11/gdkevents-x11.c: map the new GtkSettings properties
+2005-12-05 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkwidget.c:
+ * gtk/gtkuimanager.c:
+ * gtk/gtktreedatalist.c:
+ * gtk/gtktext.c:
+ * gtk/gtkmain.c:
+ * gtk/gtkitemfactory.c:
+ * gtk/gtkseparator.[hc]:
+ * gtk/gtkclist.[hc]:
+ * gtk/gtkctree.c:
+ * gtk/gtkgc.c: Use g_slice instead of mem chunks.
+
2005-12-05 Michael Natterer <mitch@imendio.com>
* gdk/x11/gdkevents-x11.c: map the new GtkSettings properties
/* length of button_actions array */
#define MAX_BUTTON 5
-/* the number rows memchunk expands at a time */
-#define CLIST_OPTIMUM_SIZE 64
-
/* the width of the column resize windows */
#define DRAG_WIDTH 6
GTK_CLIST_SET_FLAG (clist, CLIST_DRAW_DRAG_LINE);
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
- clist->row_mem_chunk = NULL;
- clist->cell_mem_chunk = NULL;
-
clist->freeze_count = 0;
clist->rows = 0;
construct_properties);
GtkCList *clist = GTK_CLIST (object);
- /* initalize memory chunks, if this has not been done by any
- * possibly derived widget
- */
- if (!clist->row_mem_chunk)
- clist->row_mem_chunk = g_mem_chunk_new ("clist row mem chunk",
- sizeof (GtkCListRow),
- sizeof (GtkCListRow) *
- CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
-
- if (!clist->cell_mem_chunk)
- clist->cell_mem_chunk = g_mem_chunk_new ("clist cell mem chunk",
- sizeof (GtkCell) * clist->columns,
- sizeof (GtkCell) * clist->columns *
- CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
-
/* allocate memory for columns */
clist->column = columns_new (clist);
columns_delete (clist);
- g_mem_chunk_destroy (clist->cell_mem_chunk);
- g_mem_chunk_destroy (clist->row_mem_chunk);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
int i;
GtkCListRow *clist_row;
- clist_row = g_chunk_new (GtkCListRow, clist->row_mem_chunk);
- clist_row->cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
+ clist_row = g_slice_new (GtkCListRow);
+ clist_row->cell = g_slice_new (GtkCell);
for (i = 0; i < clist->columns; i++)
{
if (clist_row->destroy)
clist_row->destroy (clist_row->data);
- g_mem_chunk_free (clist->cell_mem_chunk, clist_row->cell);
- g_mem_chunk_free (clist->row_mem_chunk, clist_row);
+ g_slice_free (GtkCell, clist_row->cell);
+ g_slice_free (GtkCListRow, clist_row);
}
/* FOCUS FUNCTIONS
guint16 flags;
- /* mem chunks */
- GMemChunk *row_mem_chunk;
- GMemChunk *cell_mem_chunk;
+ gpointer reserved1;
+ gpointer reserved2;
guint freeze_count;
switch (arg_id)
{
case ARG_N_COLUMNS: /* construct-only arg, only set at construction time */
- g_return_if_fail (clist->row_mem_chunk == NULL);
clist->columns = MAX (1, GTK_VALUE_UINT (*arg));
- clist->row_mem_chunk = g_mem_chunk_new ("ctree row mem chunk",
- sizeof (GtkCTreeRow),
- sizeof (GtkCTreeRow)
- * CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
- clist->cell_mem_chunk = g_mem_chunk_new ("ctree cell mem chunk",
- sizeof (GtkCell) * clist->columns,
- sizeof (GtkCell) * clist->columns
- * CLIST_OPTIMUM_SIZE,
- G_ALLOC_AND_FREE);
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
break;
case ARG_TREE_COLUMN: /* construct-only arg, only set at construction time */
ctree->tree_column = GTK_VALUE_UINT (*arg);
- if (clist->row_mem_chunk)
- ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
+ ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
break;
case ARG_INDENT:
gtk_ctree_set_indent (ctree, GTK_VALUE_UINT (*arg));
int i;
clist = GTK_CLIST (ctree);
- ctree_row = g_chunk_new (GtkCTreeRow, clist->row_mem_chunk);
- ctree_row->row.cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
+ ctree_row = g_slice_new (GtkCTreeRow);
+ ctree_row->row.cell = g_slice_new (GtkCell);
for (i = 0; i < clist->columns; i++)
{
dnotify (ddata);
}
- g_mem_chunk_free (clist->cell_mem_chunk, ctree_row->row.cell);
- g_mem_chunk_free (clist->row_mem_chunk, ctree_row);
+ g_slice_free (GtkCell, ctree_row->row.cell);
+ g_slice_free (GtkCListRow, ctree_row);
}
static void
static gint initialize = TRUE;
static GCache *gc_cache = NULL;
-static GMemChunk *key_mem_chunk = NULL;
-
GdkGC*
gtk_gc_get (gint depth,
{
GtkGCKey *new_key;
- if (!key_mem_chunk)
- key_mem_chunk = g_mem_chunk_new ("key mem chunk", sizeof (GtkGCKey),
- 1024, G_ALLOC_AND_FREE);
-
- new_key = g_chunk_new (GtkGCKey, key_mem_chunk);
+ new_key = g_slice_new (GtkGCKey);
*new_key = *key;
static void
gtk_gc_key_destroy (GtkGCKey *key)
{
- g_mem_chunk_free (key_mem_chunk, key);
+ g_slice_free (GtkGCKey, key);
}
static gpointer
static GtkItemFactoryClass *gtk_item_factory_class = NULL;
static gpointer parent_class = NULL;
static const gchar item_factory_string[] = "Gtk-<ItemFactory>";
-static GMemChunk *ifactory_item_chunks = NULL;
-static GMemChunk *ifactory_cb_data_chunks = NULL;
static GQuark quark_popup_data = 0;
static GQuark quark_if_menu_pos = 0;
static GQuark quark_item_factory = 0;
object_class->destroy = gtk_item_factory_destroy;
class->item_ht = g_hash_table_new (g_str_hash, g_str_equal);
- ifactory_item_chunks =
- g_mem_chunk_new ("GtkItemFactoryItem",
- sizeof (GtkItemFactoryItem),
- sizeof (GtkItemFactoryItem) * ITEM_BLOCK_SIZE,
- G_ALLOC_ONLY);
- ifactory_cb_data_chunks =
- g_mem_chunk_new ("GtkIFCBData",
- sizeof (GtkIFCBData),
- sizeof (GtkIFCBData) * ITEM_BLOCK_SIZE,
- G_ALLOC_AND_FREE);
quark_popup_data = g_quark_from_static_string ("GtkItemFactory-popup-data");
quark_if_menu_pos = g_quark_from_static_string ("GtkItemFactory-menu-position");
item = g_hash_table_lookup (class->item_ht, full_path);
if (!item)
{
- item = g_chunk_new (GtkItemFactoryItem, ifactory_item_chunks);
+ item = g_slice_new (GtkItemFactoryItem);
item->path = g_strdup (full_path);
item->widgets = NULL;
static void
ifactory_cb_data_free (gpointer mem)
{
- g_mem_chunk_free (ifactory_cb_data_chunks, mem);
+ g_slice_free (GtkIFCBData, mem);
}
static void
{
GtkIFCBData *data;
- data = g_chunk_new (GtkIFCBData, ifactory_cb_data_chunks);
+ data = g_slice_new (GtkIFCBData);
data->func = callback;
data->callback_type = callback_type;
data->func_data = callback_data;
*/
static GList *quit_functions = NULL; /* A list of quit functions.
*/
-static GMemChunk *quit_mem_chunk = NULL;
-
static GSList *key_snoopers = NULL;
guint gtk_debug_flags = 0; /* Global GTK debug flag */
g_return_val_if_fail ((function != NULL) || (marshal != NULL), 0);
- if (!quit_mem_chunk)
- quit_mem_chunk = g_mem_chunk_new ("quit mem chunk", sizeof (GtkQuitFunction),
- 512, G_ALLOC_AND_FREE);
-
- quitf = g_chunk_new (GtkQuitFunction, quit_mem_chunk);
+ quitf = g_slice_new (GtkQuitFunction);
quitf->id = quit_id++;
quitf->main_level = main_level;
{
if (quitf->destroy)
quitf->destroy (quitf->data);
- g_mem_chunk_free (quit_mem_chunk, quitf);
+ g_slice_free (GtkQuitFunction, quitf);
}
static gint
#define TEXT_SHOW_ADJ(text,adj,msg)
#endif
-/* Memory Management. */
-static GMemChunk *params_mem_chunk = NULL;
-static GMemChunk *text_property_chunk = NULL;
-
static GtkWidgetClass *parent_class = NULL;
text->freeze_count = 0;
- if (!params_mem_chunk)
- params_mem_chunk = g_mem_chunk_new ("LineParams",
- sizeof (LineParams),
- 256 * sizeof (LineParams),
- G_ALLOC_AND_FREE);
-
text->default_tab_width = 4;
text->tab_stops = NULL;
for (;;)
{
if (alloc)
- lp = g_chunk_new (LineParams, params_mem_chunk);
+ lp = g_slice_new (LineParams);
else
lp = &lpbuf;
{
TextProperty *prop;
- if (text_property_chunk == NULL)
- {
- text_property_chunk = g_mem_chunk_new ("text property mem chunk",
- sizeof(TextProperty),
- 1024*sizeof(TextProperty),
- G_ALLOC_AND_FREE);
- }
-
- prop = g_chunk_new(TextProperty, text_property_chunk);
+ prop = g_slice_new (TextProperty);
prop->flags = 0;
if (font)
if (prop->font)
text_font_unref (prop->font);
- g_mem_chunk_free (text_property_chunk, prop);
+ g_slice_free (TextProperty, prop);
}
/* Flop the memory between the point and the gap around like a
}
for (; cache; cache = cache->next)
- g_mem_chunk_free (params_mem_chunk, cache->data);
+ g_slice_free (LineParams, cache->data);
g_list_free (text->line_start_cache);
list = member->next;
- g_mem_chunk_free (params_mem_chunk, member->data);
+ g_slice_free (LineParams, member->data);
g_list_free_1 (member);
return list;
#include "gtktreedatalist.h"
#include "gtkalias.h"
#include <string.h>
-static GMemChunk *tree_chunk = NULL;
-#define TREE_CHUNK_PREALLOCS 64
/* node allocation
*/
{
GtkTreeDataList *list;
- if (tree_chunk == NULL)
- tree_chunk = g_mem_chunk_new ("treedatalist mem chunk",
- sizeof (GtkTreeDataList),
- sizeof (GtkTreeDataList) * TREE_CHUNK_PREALLOCS,
- G_ALLOC_AND_FREE);
-
- list = g_chunk_new (GtkTreeDataList, tree_chunk);
- memset (list, 0, sizeof (GtkTreeDataList));
+ list = g_slice_new0 (GtkTreeDataList);
return list;
}
else if (g_type_is_a (column_headers [i], G_TYPE_BOXED) && tmp->data.v_pointer != NULL)
g_boxed_free (column_headers [i], (gpointer) tmp->data.v_pointer);
- g_mem_chunk_free (tree_chunk, tmp);
+ g_slice_free (GtkTreeDataList, tmp);
i++;
tmp = next;
}
static GObjectClass *parent_class = NULL;
static guint ui_manager_signals[LAST_SIGNAL] = { 0 };
-static GMemChunk *merge_node_chunk = NULL;
-
GType
gtk_ui_manager_get_type (void)
{
gobject_class = G_OBJECT_CLASS (klass);
- if (!merge_node_chunk)
- merge_node_chunk = g_mem_chunk_create (Node, 64,
- G_ALLOC_AND_FREE);
-
gobject_class->finalize = gtk_ui_manager_finalize;
gobject_class->set_property = gtk_ui_manager_set_property;
gobject_class->get_property = gtk_ui_manager_get_property;
{
Node *mnode;
- mnode = g_chunk_new0 (Node, merge_node_chunk);
+ mnode = g_slice_new0 (Node);
mnode->type = node_type;
mnode->name = g_strndup (childname, childname_length);
{
Node *mnode;
- mnode = g_chunk_new0 (Node, merge_node_chunk);
+ mnode = g_slice_new0 (Node);
mnode->type = node_type;
mnode->name = g_strndup (childname, childname_length);
mnode->dirty = TRUE;
if (info->extra)
g_object_unref (info->extra);
g_free (info->name);
- g_chunk_free (info, merge_node_chunk);
+ g_slice_free (Node, info);
return FALSE;
}
/* --- variables --- */
static gpointer parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
-static GMemChunk *aux_info_mem_chunk = NULL;
static GtkStyle *gtk_default_style = NULL;
static GSList *colormap_stack = NULL;
static guint composite_child_stack = 0;
aux_info = g_object_get_qdata (G_OBJECT (widget), quark_aux_info);
if (!aux_info && create)
{
- if (!aux_info_mem_chunk)
- aux_info_mem_chunk = g_mem_chunk_new ("widget aux info mem chunk",
- sizeof (GtkWidgetAuxInfo),
- 1024, G_ALLOC_AND_FREE);
- aux_info = g_chunk_new (GtkWidgetAuxInfo, aux_info_mem_chunk);
+ aux_info = g_slice_new (GtkWidgetAuxInfo);
aux_info->width = -1;
aux_info->height = -1;
static void
gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
{
- g_mem_chunk_free (aux_info_mem_chunk, aux_info);
+ g_slice_free (GtkWidgetAuxInfo, aux_info);
}
static void